//
//  SZCBaseModel.m
//  礼物说
//
//  Created by dllo on 16/4/19.
//  Copyright © 2016年 sunzhichao. All rights reserved.
//

#import "SZCBaseModel.h"

@implementation SZCBaseModel

- (instancetype)initWithDic:(NSDictionary *)dic {
    self = [super init];
    if (self) {
        [self setValuesForKeysWithDictionary:dic];
    }
    return self;
}

//+ (instancetype)modelWithDic:(NSDictionary *)dic {
//    return [[[[self class] alloc] initWithDic:dic] autorelease];
//}

+ (NSMutableArray *)modelHandleWithArray:(NSArray *)array{
    // 创建Model数组
    NSMutableArray *arrModel = [NSMutableArray array];
    // 遍历字典
    for (NSDictionary *dic in array) {
        // 把字典转换成model
        SZCBaseModel *model = [[self class] modelWithDic:dic];
        // 把model添加到model 数组中
        [arrModel addObject:model];
    }
    return arrModel;
}

- (id)valueForUndefinedKey:(NSString *)key{
    return nil;
}

- (void)setValue:(id)value forKey:(NSString *)key {
    [super setValue:value forKey:key];
}

/** 容错方法*/
/**< 当Model的属性中没有和字典的key值相匹配时，进入这个方法*/
- (void)setValue:(id)value forUndefinedKey:(NSString *)key {
}

@end
